package com.hzw.saas.api.product.enums;

import java.util.Objects;

/**
 * 用户产品使用状态
 *
 * @author zzl
 * @since 02/02/2021
 */
public enum UserProductStatus {
    UNUSED(0, "未使用"),
    USED(1, "已使用");

    private final Integer value;
    private final String text;

    UserProductStatus(Integer value, String text) {
        this.value = value;
        this.text = text;
    }

    public Integer value() {
        return value;
    }

    public String text() {
        return text;
    }

    public static String text(Integer value) {
        for (UserProductStatus userProductStatus : UserProductStatus.values()) {
            if (Objects.equals(userProductStatus.value, value)) {
                return userProductStatus.text;
            }
        }
        return null;
    }

    public static UserProductStatus instance(Integer value) {
        for (UserProductStatus userProductStatus : UserProductStatus.values()) {
            if (Objects.equals(userProductStatus.value, value)) {
                return userProductStatus;
            }
        }
        return null;
    }
}
